﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Web.Caching;
using System.Windows.Forms;

namespace AiProjectCSharp.UI
{
    /// <summary>
    /// 图片检测结果
    /// </summary>
    public partial class frmDetectImg : Form
    {

        private string sourceImagePath;//原图

        private string resultImagePath;//输出结果图片

        private string resultJson;//检测结果json

        private string title; //标题
        public frmDetectImg(string sourceImagePath, string resultImagePath, string title, string resultJson)
        {
            this.sourceImagePath = sourceImagePath;
            this.resultImagePath = resultImagePath;
            this.resultJson = resultJson;
            this.Text = $"图片检测结果【{title}】";
            InitializeComponent();
        }

        private void frmDetectImg_Load(object sender, EventArgs e)
        {
            if (System.IO.File.Exists(sourceImagePath))
            {
                pictureBox_input.Image = Image.FromFile(sourceImagePath);
            }
            if (System.IO.File.Exists(resultImagePath))
            {
                pictureBox_output.Image = Image.FromFile(resultImagePath);
            }

            richTextBox_resultJson.Text = resultJson;

        }

        private void uiButton_OutPng_Click(object sender, EventArgs e)
        {

            //点击按钮时查看原图
            if (System.IO.File.Exists(sourceImagePath))
            {
                System.Diagnostics.Process.Start(sourceImagePath);
            }
        }

        private void uiButton_InputPng_Click(object sender, EventArgs e)
        {
            //点击按钮时查看原图
            if (System.IO.File.Exists(sourceImagePath))
            {
                System.Diagnostics.Process.Start(sourceImagePath);
            }
        }

        private void pictureBox_input_Click(object sender, EventArgs e)
        {
            //点击按钮时查看原图
            if (System.IO.File.Exists(sourceImagePath))
            {
                System.Diagnostics.Process.Start(sourceImagePath);
            }
        }

        private void pictureBox_output_Click(object sender, EventArgs e)
        {
            //点击按钮时查看原图
            if (System.IO.File.Exists(resultImagePath))
            {
                System.Diagnostics.Process.Start(resultImagePath);
            }
        }
    }
}
